/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.ruoyi.flink.bean;


import com.ruoyi.flink.utils.DataGenerator;

import java.io.Serializable;
import java.time.Instant;

/**
 * A TaxiFare has payment information about a taxi ride.
 *
 * <p>It has these fields in common with the TaxiRides
 * - the rideId
 * - the taxiId
 * - the driverId
 * - the startTime
 *
 * <p>It also includes
 * - the paymentType
 * - the tip
 * - the tolls
 * - the totalFare
 */
public class TaxiFare implements Serializable {

	/**
	 * Creates a TaxiFare with now as the start time.
	 */
	public TaxiFare() {
		this.startTime = Instant.now();
	}
	/**
	 * Invents a TaxiFare.
	 */
	public TaxiFare(long rideId) {
		DataGenerator g = new DataGenerator(rideId);

		this.rideId = rideId;
		this.taxiId = g.taxiId();
		this.driverId = g.driverId();
		this.startTime = g.startTime();
		this.paymentType = g.paymentType();
		this.tip = g.tip();
		this.tolls = g.tolls();
		this.totalFare = g.totalFare();
	}

	/**
	 * Creates a TaxiFare with the given parameters.
	 */
	public TaxiFare(long rideId, long taxiId, long driverId, Instant startTime, String paymentType, float tip, float tolls, float totalFare) {
		this.rideId = rideId;
		this.taxiId = taxiId;
		this.driverId = driverId;
		this.startTime = startTime;
		this.paymentType = paymentType;
		this.tip = tip;
		this.tolls = tolls;
		this.totalFare = totalFare;
	}

	public long rideId; // 乘车记录ID
	public long taxiId; // 车ID
	public long driverId;// 司机ID
	public Instant startTime; // 此乘车记录的开始时间
	public String paymentType; // 付款类型，card or cash
	public float tip; // 小费
	public float tolls; // 车费
	public float totalFare; // 总收入

	@Override
	public String toString() {
		return "TaxiFare{" +
				"rideId=" + rideId +
				", taxiId=" + taxiId +
				", driverId=" + driverId +
				", startTime=" + startTime +
				", paymentType='" + paymentType + '\'' +
				", tip=" + tip +
				", tolls=" + tolls +
				", totalFare=" + totalFare +
				'}';
	}

	@Override
	public boolean equals(Object other) {
		return other instanceof TaxiFare &&
				this.rideId == ((TaxiFare) other).rideId;
	}

	@Override
	public int hashCode() {
		return (int) this.rideId;
	}

	/**
	 * Gets the fare's start time.
	 */
	public long getEventTime() {
		return startTime.toEpochMilli();
	}

	public long getRideId() {
		return rideId;
	}

	public void setRideId(long rideId) {
		this.rideId = rideId;
	}

	public long getTaxiId() {
		return taxiId;
	}

	public void setTaxiId(long taxiId) {
		this.taxiId = taxiId;
	}

	public long getDriverId() {
		return driverId;
	}

	public void setDriverId(long driverId) {
		this.driverId = driverId;
	}

	public Instant getStartTime() {
		return startTime;
	}

	public void setStartTime(Instant startTime) {
		this.startTime = startTime;
	}

	public String getPaymentType() {
		return paymentType;
	}

	public void setPaymentType(String paymentType) {
		this.paymentType = paymentType;
	}

	public float getTip() {
		return tip;
	}

	public void setTip(float tip) {
		this.tip = tip;
	}

	public float getTolls() {
		return tolls;
	}

	public void setTolls(float tolls) {
		this.tolls = tolls;
	}

	public float getTotalFare() {
		return totalFare;
	}

	public void setTotalFare(float totalFare) {
		this.totalFare = totalFare;
	}
}
